# ui frontend

import gradio as gr
from data import ScienceDirectSource, TaylorFrancisSource  # Import the extract_calls function from data backend

ds = ScienceDirectSource()
# ds = TaylorFrancisSource() 
# Gradio interface configuration
class UI:
    def __init__(self):
        # Import the extract_calls function from data backend
        # Define Gradio interface configuration
        self.iface = gr.Interface(
            theme=gr.themes.Soft(),
            fn=ds.extract_calls,
            inputs=[
                # gr.Textbox(value="https://www.sciencedirect.com/browse/calls-for-papers?subject=computers-in-earth-sciences",
                #            text_type="text", label="目标网址",
                #            placeholder="https://www.sciencedirect.com/browse/calls-for-papers?subject=computers-in-earth-sciences",
                           # style="width: 50%; padding: 10px;"),
                gr.Textbox(value="earth", text_type="text", label="自研究关键词",
                           placeholder="earth", style="width: 50%; padding: 10px;")
            ],
            outputs=gr.DataFrame(headers=['title', 'journal', 'deadline', 'related', 'link', 'content']),
            live=False
        )

    def run(self):  # Launch Gradio interface
        self.iface.launch()
